<template>
  <div class="car">
    <el-container>
      <div>
        <el-breadcrumb separator-class="el-icon-arrow-right">
          <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
          <el-breadcrumb-item>选车中心</el-breadcrumb-item>
        </el-breadcrumb>
      </div>
      <el-container style="margin-top: 10px">
        <el-aside width="200px">
          <span class="title">全部分类</span>
          <div>
            <ul>
              <li v-for="(item,index) in options" :key="index">{{item.brandName}}</li>
            </ul>
          </div>
        </el-aside>
        <el-main>
          <div class="img" v-for="item in sites" :key="item.carId">
            <img :src=" '../../static/images/'+ item.carImg" >
            <span class="series">{{item.seriesName}}</span>
          </div>
        </el-main>
      </el-container>
      <el-footer>foot</el-footer>
    </el-container>
  </div>
</template>

<script>
export default {
  name: 'Car',
  data () {
    return {
      sites: [],
      options: []
    }
  },
  created () {
    this.getBrand()
  },
  methods: {
    handleChange (value) {
      console.log(value)
    },
    // 获取车型
    getCar () {
      this.$axios({
        methods: 'get',
        url: '/car/selectAllCar'
      })
        .then(res => {
          if (res.data.state === '200') {
            console.log(res.data.data)
            this.sites = res.data.data
          }
        })
    },

    // 获取品牌
    getBrand () {
      this.$axios({
        methods: 'get',
        url: '/brand/selectAllBrand'
      })
        .then(res => {
          if (res.data.state === '200') {
            console.log(res.data.data)
            this.options = res.data.data
            this.getCar()
          }
        })
    }
  }
}
</script>

<style scoped>
  .el-header, .el-footer {
    background-color: #B3C0D1;
    color: #333;
    text-align: center;
    line-height: 60px;
  }

  .el-aside {
    /*background-color: #D3DCE6;*/
    border:1px solid #e6e6e6;
    color: #333;
    text-align: center;
    line-height: 200px;
  }

  .el-main {
    /*background-color: #E9EEF3;*/
    color: #333;
    text-align: center;
    padding-top: 37px;
  }

  body > .el-container {
    margin-bottom: 40px;
  }

  .el-container:nth-child(5) .el-aside,
  .el-container:nth-child(6) .el-aside {
    line-height: 260px;
  }

  .el-container:nth-child(7) .el-aside {
    line-height: 320px;
  }
  .title{
    font-size: 16px;
    color: #666;
    position: relative;
    top: -75px;
    left: 0;
  }
  ul{
    width: 186px;
    list-style: none;
    position: relative;
    top: -170px;
    left: -28px;
    color: #666;
    font-size: 13px;
  }
  ul li{
    float: left;
    margin-left: 5px;
    width: 52px;
    height: 40px;
    line-height: 40px;
  }
  .img{
    float: left;
    width: 25%;
  }
  img{
    width: 280px;
    height: 210px;
  }
  .series{
    display: block;
    height: 40px;
    line-height: 40px;
    color: #444;
  }
  .car{
    width: 1450px;
    margin: 0 auto;
  }
</style>
